// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const { ccclass, property } = cc._decorator;

@ccclass
export default abstract class RecycleListItem extends cc.Component {
    protected _data: any = null;

    get data(): any {
        return this._data;
    }

    set data(value: any) {
        this._data = value;
    }

    private _dataIndex: number = -1;

    get dataIndex(): number {
        return this._dataIndex;
    }

    set dataIndex(value: number) {
        this._dataIndex = value;
    }

    private _itemIndex: number = -1;

    get itemIndex(): number {
        return this._itemIndex;
    }

    set itemIndex(value: number) {
        this._itemIndex = value;
    }

    public refresh() {
        this.labe.string = this.data;
    }

    @property(cc.Label)
    labe: cc.Label = null;

    public setPosition(pos: cc.Vec2) {
        this.node.setSiblingIndex(this.itemIndex);
        this.node.setPosition(pos);
    }

    public show() {
        this.node.active = true;
    }

    public hide() {
        this.node.active = false;
    }
}